package cn.com.gof.structure.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>Title: ChessFlyWeightFactory</p>  
 * <p>Description: </p>  
 * @author WangJun
 * @date 2018年9月7日 下午2:30:50
 */
public class ChessFlyWeightFactory {
	//享元池
	private static Map<String,ChessFlyWeight> map = new HashMap<String,ChessFlyWeight>();
	
	public static ChessFlyWeight getChess(String color) {
		if(map.get(color) != null) {
			return map.get(color);
		} else {
			ConcreateChess chess = new ConcreateChess(color);
			map.put(color, chess);
			return chess;
		}
	}
}
